Cocoa - SGDataProc Sample Read Me

Version 1.0
May 23 2002

Description

This sample is based on the existing SGDataProc sample, which is a Carbon application. This sample demonstrates how to use a Sequence Grabber data function in the Cocoa environment to simulate a "preview" operation for the captured video data. A NSQuickDrawView is used for display of the data.

When a data function is specified for a given sequence grabber channel, this function is called whenever the channel decides to write movie data to the designated destination. Our particular data function code first draws this data into an offscreen gworld using a decompression sequence, where any additional manipulations can be performed on the data (overlaying text, for example). Finally, another decompression sequence is used to draw the data from the gworld to a window.

Our window actually consists of a NSQuickDrawView contained inside an NSWindow. We use NSQuickDrawView because it provides a convenient drawing space and it also contains the "qdPort" method. This method returns the QuickDraw GrafPtr associated with the view. We use this GrafPtr as the destination for our decompression sequence when drawing from the gworld to our NSQuickDrawView. However, keep in mind the GrafPtr returned by the qdPort method is valid only while the view has focus. Outside of focus, it is undefined.

The technique we use to draw into our NSQuickDrawView is this - we implement the NSView drawRect method. In our drawRect method we use a decompression sequence to draw into the GrafPtr for our NSQuickDrawView. To "trigger" this drawing to occur, we call the NSView "display" method from our sequence grabber data function. This forces our drawRect method to get called, which displays our data.

Using The Application

Simply connect your camera, the launch the application. You'll see a preview of the captured video in the window. Note: if your camera is not connected before launching the application, no video data is displayed (the application does not re-scan for subsequent connections).

Compiler Requirements

Project Builder 1.1.1 (December 2001 Developer Tools) or better

RunTime Requirements

Mac OS X or better
